/* 
* This module is part of the Entertainment Network system 
* Copyright (c) SCC Soft Computer, Inc. 2018 
* All Rights Reserved 
* 
* This document contains unpublished, confidential and proprietary 
* information of SCC Soft Computer, Inc. No disclosure or use of 
* any portion of the contents of these materials may be made without the 
* express written consent of Soft Computer Consultants, Inc. 
* 
*/ 

package isd.dp.ua.EntertainmentNetworkServer.Models;
// Generated Feb 9, 2018 5:32:55 PM by Hibernate Tools 3.5.0.Final

import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.*;
import javax.xml.bind.annotation.*;

import isd.dp.ua.EntertainmentNetworkServer.Common.BaseModel;

/**
 * Cinema generated by hbm2java
 */
@SuppressWarnings("serial")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType
@Entity
@Table(name = "CINEMA", schema = "PBAB")
public class Cinema extends BaseModel implements java.io.Serializable
{
	private BigDecimal cinId;
	@XmlTransient
	private City city;	
	private String cinName;
	private byte[] cinIcon;
	private String cinAddress;
	private Set<Hall> halls = new HashSet<Hall>(0);

	public Cinema()
	{
	}

	public Cinema(BigDecimal cinId, City city, String cinName, String cinAddress)
	{
		this.cinId = cinId;
		this.city = city;
		this.cinName = cinName;
		this.cinAddress = cinAddress;
	}

	public Cinema(BigDecimal cinId, City city, String cinName, byte[] cinIcon, String cinAddress, Set<Hall> halls)
	{
		this.cinId = cinId;
		this.city = city;
		this.cinName = cinName;
		this.cinIcon = cinIcon;
		this.cinAddress = cinAddress;
		this.halls = halls;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CINEMA_SEQ")
    @SequenceGenerator(name = "CINEMA_SEQ", sequenceName = "CINEMA_SEQ")
	@Column(name = "CIN_ID", unique = true, nullable = false, precision = 22, scale = 0)
	public BigDecimal getCinId()
	{
		return this.cinId;
	}

	public void setCinId(BigDecimal cinId)
	{
		this.cinId = cinId;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "CIN_CITY_ID", nullable = false)
	public City getCity()
	{
		return this.city;
	}

	public void setCity(City city)
	{
		this.city = city;
	}
	
	@Transient
	@XmlElement
	public BigDecimal getCityId()
	{
		return this.getCity() == null ? new BigDecimal("-1") : this.getCity().getCitId();
	}

	@Column(name = "CIN_NAME", nullable = false, length = 100)
	public String getCinName()
	{
		return this.cinName;
	}

	public void setCinName(String cinName)
	{
		this.cinName = cinName;
	}

	@Column(name = "CIN_ICON")
	public byte[] getCinIcon()
	{
		return this.cinIcon;
	}

	public void setCinIcon(byte[] cinIcon)
	{
		this.cinIcon = cinIcon;
	}

	@Column(name = "CIN_ADDRESS", nullable = false)
	public String getCinAddress()
	{
		return this.cinAddress;
	}

	public void setCinAddress(String cinAddress)
	{
		this.cinAddress = cinAddress;
	}

	@OneToMany(cascade={CascadeType.MERGE}, fetch = FetchType.EAGER, mappedBy = "cinema")
	public Set<Hall> getHalls()
	{
		return this.halls;
	}

	public void setHalls(Set<Hall> halls)
	{
		this.halls = halls;
	}

	@Override
	public String toString()
	{
		return "Cinema [cinId=" + cinId + ", cinName=" + cinName + "]";
	}
}
